using Emgu.CV;
using System.Collections.Generic;

namespace DualCameraApp.Models;

public static class CameraService
{
    public static List<int> GetAvailableCameras()
    {
        var cameras = new List<int>();
        for (int i = 0; i < 10; i++) // 检查前10个摄像头索引
        {
            using var capture = new VideoCapture(i);
            if (capture.IsOpened)
            {
                cameras.Add(i);
            }
        }
        return cameras;
    }
    
    public static bool IsCameraAvailable(int index)
    {
        using var capture = new VideoCapture(index);
        return capture.IsOpened;
    }
}